"""
    Simple lookup for viewing temporary payment records table for cashiers.
"""

from mnemoply.controllers.TemporaryPaymentRecord import TemporaryPaymentRecordController
from mnemoply.utils import update_with

class TemporaryPaymentRecordControllerForCashier(TemporaryPaymentRecordController):
    def _get_edit_fields(self, obj):
        fields = [
            'informationSourceID',
            'eventID',
            'payment',
            'date',
            'registerID',
            'comment',
        ]
        if obj.studentAgreement is None:
            fields = update_with(fields, [
                'organizationID',
                'trendID',
                'tariffID',
                ])
        if obj.student is None:
            fields = update_with(fields, [
                'tempSurname',
                'tempForename',
                'tempPatronymic',
                'phone',
                ])
        return fields

    def _update_kw(self, obj, kw):
        result = kw
        del result['studentID']
        del result['studentAgreementID']
        if obj.studentAgreement:
            del result['organizationID']
            del result['trendID']
            del result['tariffID']
        if obj.student:
            del result['tempSurname']
            del result['tempForename']
            del result['tempPatronymic']
            del result['phone']
        return result

    def __init__(self):
        TemporaryPaymentRecordController.__init__(self)
        self.title = _("Payments for cashiers")

exposed = TemporaryPaymentRecordControllerForCashier()
